# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: Manolis Tzanidakis

pkgname=perl-net-ssleay
_cpanname=Net-SSLeay
pkgver=1.85
pkgrel=2
pkgdesc='Perl extension for using OpenSSL'
url='https://search.cpan.org/dist/Net-SSLeay/'
arch=('x86_64')
license=('custom:BSD')
depends=('openssl')
makedepends=('chrpath')
replaces=('net-ssleay')
provides=('net-ssleay')
options=('!emptydirs')
source=(https://www.cpan.org/authors/id/M/MI/MIKEM/${_cpanname}-${pkgver}.tar.gz)
sha512sums=('74e0f2f56b707f1ff845c78c1fa7ce26a71b8f943bb99e994d4e065d1f42259fe4cd1a6a17d333459727534158f9541f116dbc8515122380807d9450b0faa26b')

prepare() {
  cd ${_cpanname}-${pkgver}
  sed -i \
      -e "/\$opts->{optimize} = '-O2 -g';/d" \
      inc/Module/Install/PRIVATE/Net/SSLeay.pm
}

build() {
  cd ${_cpanname}-${pkgver}
  export OPTIMIZE="${CFLAGS}"
  export OPENSSL_PREFIX=/usr
  PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
  make
}

check() {
  cd ${_cpanname}-${pkgver}
  make test
}

package() {
  cd ${_cpanname}-${pkgver}

  make install DESTDIR="${pkgdir}"
  install -Dm 644 README "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  # strip rpath
  find "${pkgdir}" -name '*.so' -exec chrpath -d '{}' \;
}

# vim: ts=2 sw=2 et:
